<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/templates/templateListar.xhtml">

	<ui:define name="conteudo">
		<ui:param name="actionBean" value="#{animalMB.animalDetalheMB}" />
		<p:growl id="mensagem" showDetail="true" autoUpdate="false"
			closable="true" />
		<p:panel id="dialogCadastro" width="100%" height="80%"
			closable="false" widgetVar="dialogCadastroAnimal"
			header="Cadastro de Animal">
			<h:form id="frmAnimalDialog">

				<p:hotkey bind="esc"
					handler="document.getElementById('frmAnimalDialog:btnCancelar').click()" />


				<h:panelGrid columns="2" style="horizontal-align:center">
					<p:outputLabel value="Codigo:" />
					<p:inputText id="codigo"
						value="#{animalMB.animalDetalheMB.animal.codigo}" disabled="true" />

					<p:outputLabel for="nome" value="Nome:" />
					<p:focus for="nome">
						<p:inputText id="nome" value="#{animalMB.animalDetalheMB.animal.nome}"
							disabled="#{animalMB.animalDetalheMB.consultando}" required="true"
							maxlength="50" requiredMessage="Nome é obrigatório!" />
					</p:focus>
					<p:outputLabel value="Data Nascimento:" for="dataNasc" />
					<p:inputMask value="#{animalMB.animalDetalheMB.animal.dataNascimento}"
						disabled="#{animalMB.animaldetalheMB.consultando}" required="true"
						maxlength="8" requiredMessage="Data de Nascimento é obrigatória!"
						id="dataNasc" mask="99/99/9999">
						<f:convertDateTime pattern="dd/MM/yyyy" timeZone="GMT-3" />
					</p:inputMask>

					<p:outputLabel value="DataCadastro:" />
					<p:inputText id="dataCadastro"
						value="#{animalMB.animalDetalheMB.animal.dataCadastro}"
						disabled="#{animalMB.animalDetalheMB.consultando}" maxlength="50"
						validatorMessage="E-mail inválido">
						<f:validateRegex
							pattern="^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$" />
					</p:inputText>



				</h:panelGrid>
				<p:panel header="Endereço">
					<h:panelGrid columns="2">
						<p:outputLabel value="Logradouro:" for="logradouro" />
						<p:inputText id="logradouro"
							disabled="#{animalMB.animalDetalheMB.consultando}" required="true"
							value="#{animalMB.animalDetalheMB.animal.endereco.logradouro}" size="40"
							maxlength="60" />


						<p:outputLabel value="Número:" />
						<p:inputText id="numero"
							disabled="#{animalMB.animalDetalheMB.consultando}"
							value="#{animalMB.animalDetalheMB.animal.endereco.numero}" size="15"
							onkeypress="return(mascaras(this,numero))" maxlength="10" />

						<p:outputLabel value="Complemento:" />
						<p:inputText id="compl"
							disabled="#{animalMB.animalDetalheMB.consultando}"
							value="#{animalMB.animalDetalheMB.animal.endereco.complemento}" size="15"
							maxlength="20" />


						<p:outputLabel value="Bairro:" for="bairro" />
						<p:inputText id="bairro"
							disabled="#{animalMB.animalDetalheMB.consultando}" required="true"
							value="#{animalMB.animalDetalheMB.animal.endereco.bairro}" size="40"
							maxlength="50" />

						<p:outputLabel value="CEP:" for="cep" />
						<p:inputMask id="cep" disabled="#{animalMB.animalDetalheMB.consultando}"
							required="true" value="#{animalMB.animalDetalheMB.animal.endereco.cep}"
							size="15" maxlength="9" mask="99999-999" />


						<p:outputLabel value="UF:" />
						<p:selectOneMenu id="uf" filterMatchMode="contains" filter="true"
							value="#{animalMB.animalDetalheMB.animal.endereco.uf}"
							disabled="#{animalMB.animalDetalheMB.consultando}"
							style="width:150px;font-size:10px">
							<f:selectItems value="#{animalMB.animalDetalheMB.listaEstado}" var="uf"
								itemLabel="#{uf.uf}" itemValue="#{uf}"></f:selectItems>

						</p:selectOneMenu>


						<p:outputLabel value="Cidade:" for="cidade" />
						<p:inputText id="cidade"
							disabled="#{animalMB.animalDetalheMB.consultando}" required="true"
							value="#{animalMB.animalDetalheMB.animal.endereco.cidade}" size="40"
							maxlength="50" />




					</h:panelGrid>
				</p:panel>

				<h:panelGrid columns="6">
					<p:commandButton id="btnConfirma"
						action="#{animalMB.animalDetalheMB.salvar}" value="Confirma"
						update=":mensagem" />


					<p:commandButton id="btnCancelar" value="Cancelar" immediate="true"
						action="#{actionBean.sair}" />

				</h:panelGrid>

			</h:form>
		</p:panel>
	</ui:define>
</ui:composition>
</html>